package com.mani.geotag;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;


public class MapWidgetProvider2x2 extends AppWidgetProvider{
	boolean isFirstTimeInstance = true;
	private final int DELETE_ID = -100;
	private final int ENABLED_ID = -101;
    public static final String PREFS_NAME = "MapWidgetPrefs";
    
	public void onUpdate(Context context, AppWidgetManager appWidgetManager,int[] appWidgetIds) {
	      int N = appWidgetIds.length;
	      int appWidgetId =0;
	      for (int i=0; i<N; i++) {
	    	  appWidgetId = appWidgetIds[i];
	      }
		  Intent serviceIntent = new Intent(context, MapService.class);
		  serviceIntent.putExtra("appwidgetid", appWidgetId);
		  serviceIntent.putExtra("appwidgettype", 1);
		  context.startService(serviceIntent);
	}
	
	public void onDeleted(Context context, int[] appWidgetIds)
	{
      super.onDeleted(context, appWidgetIds);
      int N = appWidgetIds.length;
      int appWidgetId =0;
      for (int i=0; i<N; i++) {
    	  appWidgetId = appWidgetIds[i];
      }
	  Intent serviceIntent = new Intent(context, MapService.class);
	  serviceIntent.putExtra("deleteAppWidgetId", appWidgetId);
	  serviceIntent.putExtra("appwidgetid", DELETE_ID);
	  context.startService(serviceIntent);
	}
	
	public void onEnabled(Context context)
	{
        Intent serviceIntent = new Intent(context, MapService.class);
        serviceIntent.putExtra("appwidgetid", ENABLED_ID);
        serviceIntent.putExtra("appwidgettype", 1);
        context.startService(serviceIntent);
    }
	
	public void onDisabled(Context context)
	{
		Intent serviceIntent = new Intent(context, MapService.class);
		//context.stopService(serviceIntent);	Service must be serving for 4x2 widgets.
	}
}
